{% extends "base.html" %}

{% block content %}
<div id="topics">
<h2>Add / Edit Document</h2>
<br/>

    <div id="entryform">
          <form action="/editdocument" method="post" onsubmit="return validate_postdocument(this)">
            <label>Title:</label>
            <input class="textbox" name="title" value="{{ document.title }}"><br>
            <label>Summary:</label>
            <textarea name="summary" rows="4">{{ document.summary }}</textarea><br>
            <label>Image URL:</label>
            <input class="textbox" name="imagelink" value="{% if defaultimage %}{{ defaultimage }}{% endif %}{% if document.imagelink %}{{ document.imagelink }}{% endif %}"><br>
            {% if document.imagelink %}
            <label>Image:</label>
            <img src="{{ document.imagelink }}"><br>
            {% endif %}
            <label>Document URL:</label>
            <input class="textbox" name="location" value="{% if document.location %}{{ document.location }}{% endif %}"><br>
            <label>Categories:</label>
                {% for navdoccategory in navdoccategories %}
                <input type="checkbox" name="categories" value="{{ navdoccategory }}" {% for category in document.categories %}{% ifequal category navdoccategory %}checked="checked"{% endifequal %}{% endfor %}>{{ navdoccategory }}</input>
                {% endfor %}
            <br>
            <label>Page count:</label>
            <input name="pages" class="textbox" value="{{ document.pages }}"><br>
            <label>Published?:</label>
            <input name="published" type="checkbox" {% if document.published %}checked="checked"{% endif %}><br>
            <label></label>
            <input type="submit" name="action" value="Save Article">{% if document.key %}<input type="submit" name="action" value="Delete" onclick="return confirm('Are you sure you want to permanently delete this Document?');"/>{% endif %}
            <input type="hidden" name="documentkey" value="{{ document.key }}">
            <br>
          </form>
    </div>
</div>
{% endblock %}